package chapter3.e4;

class Student{
    private String name;
    private int age;
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    public int getAge(){
        return age;
    }
    public void setAge(int age){
        if (age<=0){
            System.out.println("您输入的年龄有误!");
        }else{
            this.age=age;
        }
    }
   public void read(){
        System.out.println("大家好,我是"+name+",年龄"+age);
    }
}
public class Example4 {
    public static void main(String[]args){
        Student stu1 = new Student();
        stu1.setName("张三");
        stu1.setAge(-18);
        stu1.read();
    }
}
